import request from '@/utils/request'
// import qs from 'qs'

// 删除URL类
export function delUrlClass (params) {
  var data = fromData(params)
  return request({
    url: '/url/del_urlClass',
    method: 'post',
    data
  })
}

// 增加URL类
export function addUrlClass (params) {
  var data = fromData(params)
  return request({
    url: '/url/addUrlClass',
    method: 'post',
    data
  })
}

// 编辑URL类
export function editUrlClass (params) {
  var data = fromData(params)
  return request({
    url: '/url/editUrlClass',
    method: 'post',
    data
  })
}

// 获取URL类列表
export function getUrlClassArray (params) {
  var data = fromData(params)
  return request({
    url: '/url/getUrlClassArray',
    method: 'post',
    data
  })
}

// 获取URL类信息
export function getUrlClassInfo (params) {
  var data = fromData(params)
  return request({
    url: '/url/getUrlClassInfo',
    method: 'post',
    data
  })
}

// 删除URL策略
export function delUrl (params) {
  var data = fromData(params)
  return request({
    url: '/url/del_url',
    method: 'post',
    data
  })
}

// 增加URL策略
export function addUrl (params) {
  var data = fromData(params)
  return request({
    url: '/url/addUrl',
    method: 'post',
    data
  })
}

// 编辑URL策略
export function editUrl (params) {
  var data = fromData(params)
  return request({
    url: '/url/editUrl',
    method: 'post',
    data
  })
}

// 获取URL策略列表
export function getUrlArray (params) {
  var data = fromData(params)
  return request({
    url: '/url/getUrlArray',
    method: 'post',
    data
  })
}

// 获取URL策略信息
export function getUrlInfo (params) {
  var data = fromData(params)
  return request({
    url: '/url/getUrlInfo',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
